use crate::REDIS_URL;
use redis::{Client, Connection};
use std::time::Duration;

/// 获取redis连接
pub fn get_connection() -> Connection {
    let redis_url = REDIS_URL.clone();
    let client = Client::open(redis_url.clone())
        .expect(&format!("连接Redis服务器失败！连接地址：{redis_url}"));
    client
        .get_connection_with_timeout(Duration::from_secs(2))
        .expect("获取Redis连接失败！")
}
